import { Router, Route, Switch, Redirect } from 'react-router-dom'
import React, { Suspense } from 'react'
import AuthRoute from 'components/AuthRoute'
import history from 'utils/history'
// import Layout from './pages/Layout'
// import Login from './pages/Login'
const Login = React.lazy(() => import('pages/Login'))
const Layout = React.lazy(() => import('pages/Layout'))
function App() {
  return (
    <Router history={history}>
      <div className="App">
        <Suspense fallback={<div>loading...</div>}>
          <Switch>
            <Redirect exact from="/" to="/home"></Redirect>
            {/* <Route path="/home" component={Layout}></Route> */}
            <AuthRoute path="/home" component={Layout}></AuthRoute>
            <Route path="/login" component={Login}></Route>
            {/* <Route
            path="/login"
            render={(props) => {
              return <Login {...props}></Login>
            }}
          ></Route> */}
          </Switch>
        </Suspense>
      </div>
    </Router>
  )
}

export default App
